/**
 * 
 */
package com.nh.common;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.tdkj.util.PublicConfing;

/**
 * 项目名称：NotoginsengManage
 * 
 * 类名称：AdminManagerInterceptor
 * 
 * 类描述： 管理员验证拦截器
 * 
 * 创建人：李兴建
 * 
 * E-mail:lxj08193@163.com
 * 
 * 创建时间：2012-11-6 下午04:05:11
 * 
 * 修改人：李兴建
 * 
 * 修改时间：2012-11-6 下午04:05:11
 * 
 * 修改备注：
 * 
 * @version
 */
public class AdminManagerInterceptor extends AbstractInterceptor {
	/*
	 * (non-Javadoc) 验证管理是否登录或session是否过期 ，验证失败刚跳转到登录页面
	 * 
	 * @see
	 * com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com
	 * .opensymphony.xwork2.ActionInvocation)
	 */
	@Override
	public String intercept(ActionInvocation interceptor) throws Exception {
		if (null == interceptor.getInvocationContext().getSession().get(PublicConfing.ADMINISTRATOR_ADMIN_OBJ_STRING_CONFIG)) {
			HttpServletRequest request = ServletActionContext.getRequest();
			StringBuffer url = request.getRequestURL();
			if (request.getQueryString() != null) {
				url.append("?");
				url.append(request.getQueryString());
			}
			// System.out.println("绝对路径:" + url);
			interceptor.getInvocationContext().getSession().put(PublicConfing.REDIRECTURL_TEMP, url.toString());

			return Action.LOGIN;
		} else {
			return interceptor.invoke();
		}
	}

}
